/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 1000;
    vc.extends({
        data: {
            inspectionPlanDetailInfo: {
                beforeTime: "",
                canReexamine: "",
                createTime:"",
                createUserId:"",
                createUserName:"",
                endDate:"",
                endTime :"",
                inspectionDay:"",
                inspectionMonth:"",
                inspectionPlanId:"",
                inspectionPlanName:"",
                inspectionPlanPeriod:"",
                inspectionPlanPeriodName:"",
                inspectionRouteId:"",
                inspectionRouteName :"",
                inspectionWorkday :"",
                remark:"",
                signType:"",
                signTypeName:"",
                startDate:"",
                startTime :"",
                state :"",
                stateName:"",
                total: 0,
                records: 1,
                moreCondition: false,
                inspectionName: '',
                pointObjTypes: [],
                _currentTab: 'inspectionPlanDetailStaff',
            }
        },
        _initMethod: function () {
            $that.inspectionPlanDetailInfo.inspectionPlanId = vc.getParam('inspectionPlanId');
            //与字典表关联
            vc.getDict('inspection_point', "point_obj_type", function (_data) {
                $that.inspectionPlanDetailInfo.pointObjTypes = _data;
            });
            $that._listInspectionPlanDetails(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {
            vc.on('inspectionPlanDetail', 'listInspectionPlanDetail', function (_param) {
                $that._listInspectionPlanDetails(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listInspectionPlanDetails(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listInspectionPlanDetails: function (_page, _rows) {
                let param = {
                    params: {
                        page:1,
                        row:1,
                        communityId:vc.getCurrentCommunity().communityId,
                        inspectionPlanId:$that.inspectionPlanDetailInfo.inspectionPlanId
                    }
                };
                //发送get请求
                vc.http.apiGet('/inspectionPlan.listInspectionPlans',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                       vc.copyObject(_json.data[0],$that.inspectionPlanDetailInfo);
                       $that.changeTab($that.inspectionPlanDetailInfo._currentTab);
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
           
            //查询
            _queryInspectionPlanDetailMethod: function () {
                $that._listInspectionPlanDetails(DEFAULT_PAGE, DEFAULT_ROWS);
            },
       
            changeTab: function (_tab) {
                $that.inspectionPlanDetailInfo._currentTab = _tab;
                vc.emit(_tab, 'switch', {
                    inspectionPlanId:$that.inspectionPlanDetailInfo.inspectionPlanId,
                    inspectionRouteId:$that.inspectionPlanDetailInfo.inspectionRouteId
                });
            },
            _moreCondition: function () {
                if ($that.inspectionPlanDetailInfo.moreCondition) {
                    $that.inspectionPlanDetailInfo.moreCondition = false;
                } else {
                    $that.inspectionPlanDetailInfo.moreCondition = true;
                }
            },
            _pointQrCode: function (_inspectionPlanDetail) {
                vc.emit('inspectionPlanDetailQrCode', 'openInspectionPlanDetailQrCodeModal', _inspectionPlanDetail);

            }
        }
    });
})(window.vc);